// form select
var formSelect = $('.m-search-select');
if(formSelect.length) {

	var menu = $('.m-search-select-menu', formSelect),
		form = formSelect.parents('form');

	formSelect.hover(function(){
		$(this).addClass('m-search-select-open');
	}, function(){
		$(this).removeClass('m-search-select-open');
	});
	
	$('li', formSelect).hover(function(){
		$(this).addClass('hover');
	}, function(){
		$(this).removeClass('hover');
	});
	
	menu.delegate('li', 'click', function(){
		var li = $(this),
			action = li.attr('data-action') || '/root/',
			text = li.text(),
			placeholder = $('.m-search-select-selected', formSelect);
		
		placeholder.text(text);
		formSelect.removeClass('m-search-select-open');
		form.attr('action', action);
	});
	
}